<!--
  @author heguanghua
  @since 2019/06/12 11:57
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:include="common/common::jscss2"/>
<body>

<div class="layui-fluid">

    <blockquote class="layui-crumb">
        渠道管理>
        <a lay-href="/channel/list.action">渠道管理</a>>
        <zmn th:text="${(obj.channelId eq null) ? '新增一级渠道' : obj.name}">新增或修改渠道</zmn>
    </blockquote>

    <div class="layui-card">

        <div th:replace="channel/_tab::tab"></div>

        <div class="layui-card-body">

            <form method="POST" action="" class="layui-form" lay-filter="zmn-form">

                <input type="hidden" name="channelId" th:value="${obj.channelId}"/>
                <input type="hidden" id="rank" name="rank" value="1"/>

                <div class="layui-card-header layui-margin-b"><b>基本信息</b></div>

                <div class="layui-form-item" th:if="${obj.channelId > 0}">
                    <label class="layui-form-label">渠道ID：</label>
                    <div class="layui-input-block">
                        <div class="layui-form-mid">
                            <span th:text="${obj.channelId}">ID</span>
                            <span style="font-family:'ArialMT', 'Arial';color:#33AB9F;"
                                  th:text="${obj.status == 2 ? '正常' : '停用'}">status</span>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">渠道名称：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input type="text" name="name" th:disabled="${obj.name != null and !detailNameUpdate}"
                               th:value="${obj.name}" placeholder="渠道名称" lay-verify="required" lay-verType="tips"
                               autocomplete="off" class="layui-input" maxlength="300"/>
                    </div>
                    <span class="layui-form-label" style="width: auto; color: #9F9F9F;">系统显示使用该名称</span>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">渠道别名：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input type="text" name="anotherName" th:value="${obj.anotherName}" placeholder="渠道别名"
                               lay-verify="" lay-verType="tips" autocomplete="off" class="layui-input" maxlength="300"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">所属平台：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <select lay-filter="plat" id="plat" name="plat" lay-search lay-verify="required">
                            <option value=""></option>
                            <option th:each="plat:${plats}" th:value="${plat.key}" th:selected="${plat.key == obj.plat}"
                                    th:text="${plat.value}"/>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">渠道类型：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <select lay-filter="channelType" name="channelType" lay-search lay-verify="required"
                                th:disabled="${channelTypeEnable ? true : false}">
                            <option value=""></option>
                            <option th:each="channelType:${channelTypes}" th:value="${channelType.code}"
                                    th:selected="${channelType.code == obj.channelType}" th:text="${channelType.name}"/>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item" id="companyIdDiv" th:hidden="${obj.channelType == 7}">
                    <label id="companyLabel" class="layui-form-label layui-form-required">渠道公司：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <div id="companyId"></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">渠道等级：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <select name="level" lay-search lay-verify="required">
                            <option value=""></option>
                            <option th:each="channelLevel:${channelLevels}" th:value="${channelLevel.code}"
                                    th:selected="${channelLevel.code == obj.level}" th:text="${channelLevel.name}"/>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">客户类型：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <select name="customerType" lay-search lay-verify="required">
                            <option value=""></option>
                            <option th:each="customerType:${customerTypes}" th:value="${customerType.code}"
                                    th:selected="${customerType.code == obj.customerType}"
                                    th:text="${customerType.name}"/>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">接入方式：</label>
                    <div class="layui-input-inline" style="width:870px">
                        <th:block th:each="item:${channelAccessModes}" th:title="${item.value}">
                            <input type="checkbox" name="accessMode" th:value="${item.key}"
                                   th:checked="${obj.accessMode != null && #strings.contains(obj.accessMode, item.key)}"
                                   th:title="${item.value}" lay-verify="required">
                        </th:block>
                    </div>
                    <span class="layui-form-label" style="width: auto; color: #9F9F9F;">网络客服接入，可在：快捷下单页面下单</span>
                </div>

                <div class="layui-card-header layui-margin-b"><b>商务信息</b></div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">商务部门：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <div id="deptId"></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">商务BD：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <div id="salesman"></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">运营部门：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <div id="abutmentDeptId" lay-filter="abutmentDeptId"></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">运营责任人：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <div id="abutmenter"></div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">合同模式：</label>
                    <div class="layui-input-inline" style="width:280px">
                        <input type="radio" th:disabled="${obj.contractModel != null ? true: false}"
                               name="contractModel" lay-filter="contractModel" value="1"
                               th:checked="${obj.contractModel == 1}" title="平台代收合同" lay-verify="required">
                        <input type="radio" th:disabled="${obj.contractModel != null ? true: false}"
                               name="contractModel" lay-filter="contractModel" value="2"
                               th:checked="${obj.contractModel == 2}" title="维修服务合同" lay-verify="required">
                    </div>
                    <span class="layui-form-label"
                          style="width: auto; color: #9F9F9F;">渠道合同模式，决定订单支付收款主体；新增后，不可更改，请认真选择</span>
                </div>

                <div class="layui-form-item" id="subCompanyContractDiv"
                     th:hidden="${obj.subCompanyId == null || obj.subCompanyId == ''}">
                    <label class="layui-form-label layui-form-required">子公司合同：</label>
                    <div id="subCompanyDiv" class="layui-input-inline"
                         style="width:260px">
                        <select th:disabled="${obj.subCompanyId != null ? true: false}" lay-filter="subCompanyId"
                                id="subCompanyId" name="subCompanyId" lay-search>
                            <option value=""></option>
                            <option th:each="subCompany:${currentPlatSubCompanyList}" th:value="${subCompany.companyId}"
                                    th:selected="${subCompany.companyId == obj.subCompanyId}"
                                    th:text="${subCompany.fullName}"/>
                        </select>
                    </div>
                    <span class="layui-form-label"
                          style="width: auto; color: #9F9F9F;">该渠道是子公司签的合同；新增后，不可更改，请认真选择</span>
                </div>

                <div class="layui-form-item" id="hideContractTimeRange">
                    <label class="layui-form-label layui-form-required">合同起止日期：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input th:if="${obj.channelId == null}" type="text" id="contractTimeRange"
                               name="contractTimeRange" placeholder="yyyy/MM/dd - yyyy/MM/dd" autocomplete="off"
                               class="layui-input" lay-verify="contractTimeRange"/>
                        <input th:if="${obj.channelId > 0}" type="text" id="contractTimeRange" name="contractTimeRange"
                               th:value="${obj.contractStartDate == null ? '' : #dates.format(obj.contractStartDate, 'yyyy/MM/dd') + ' - ' + #dates.format(obj.contractExpiresDate, 'yyyy/MM/dd')}"
                               placeholder="yyyy/MM/dd - yyyy/MM/dd" autocomplete="off" class="layui-input"
                               lay-verify="contractTimeRange"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">打款给渠道：</label>
                    <div class="layui-input-inline" style="width:300px">
                        <input type="radio" name="checkCompanyBank" value="2"
                               th:checked="${obj.checkCompanyBank == 2}" title="是" lay-verify="required">
                        <input type="radio" name="checkCompanyBank" value="1"
                               th:checked="${obj.checkCompanyBank == 1}" title="否" lay-verify="required">
                    </div>
                </div>
                <zmn th:if="${obj.channelId > 0}">
                    <div class="layui-card-header layui-margin-b"><b>其他信息</b></div>

                    <div class="layui-form-item layui-form-item-sm">
                        <label class="layui-form-label">修改人/时间：</label>
                        <div class="layui-input-block">
                            <div class="layui-form-mid layui-word-aux"
                                 th:text="${obj.updater} + '&nbsp;/&nbsp;' + ${#dates.format(obj.updateTime, 'yyyy-MM-dd HH:mm:ss')}">
                                修改人/时间
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-item-sm">
                        <label class="layui-form-label">创建人/时间：</label>
                        <div class="layui-input-block">
                            <div class="layui-form-mid layui-word-aux"
                                 th:text="${obj.creater} + '&nbsp;/&nbsp;' + ${#dates.format(obj.createTime, 'yyyy-MM-dd HH:mm:ss')}">
                                创建人/时间
                            </div>
                        </div>
                    </div>
                </zmn>

                <div class="layui-form-item submit"
                     th:if="${#authPermit.checkPermit('/channel/addEdit.action') || (#authPermit.checkPermit('/channel/add.action') && addFlag == '1')}">
                    <div class="layui-input-inline" style="margin-left: 150px">
                        <a class="layui-btn" lay-submit="" lay-filter="zmn-form-submit-one">提交</a>
                        <button type="reset" class="layui-btn layui-btn-primary">取消</button>
                    </div>
                    <div class="layui-input-inline" style="margin-left: -20px">
                        <div style="width: 600px; color: #9F9F9F;">
                            一级渠道同理二级渠道进行渠道相关配置，若二级渠道未配置，则取上级一级渠道配置（此处配置不包括）新增后：渠道状态为“禁用”
                        </div>
                    </div>
                </div>

            </form>

            <div th:if="${obj.channelId > 0}" class="layui-card-header layui-margin-b" style="margin-left: -10px"><b>操作记录信息</b>
            </div>

            <div th:replace="channel/_logs::table"></div>

        </div>

    </div>

</div>
</body>
</html>
<style type="text/css">
    .laytable-cell-1-0-3 {
        height: auto !important;
    }
    xm-select[size='mini'] {
        min-height: 36px;
        line-height: 36px;
        font-size: 14px;
    }
    xm-select[size='mini'] .xm-label .xm-label-block {
        height: 26px;
        line-height: 26px;
    }
</style>
<script type="text/javascript" th:inline="javascript">

    var json = {
        query: [[${query}]],
        totalCount: [[${query.totalCount}]],
        pageSize: [[${query.pageSize}]],
        pageIndex: [[${query.pageIndex}]],
        provinces: [[${provinces}]],
        citys: [[${citys}]],
        provinceId: [[${obj.provinceId}]],
        cityId: [[${obj.cityId}]],
        plats: [[${plats}]],
        allSubCompanyList: [[${allSubCompanyList}]],
        oneDepts: [[${oneDepts}]],
        twoDepts: [[${twoDepts}]],
        obj: [[${obj}]],
        addFlag: [[${addFlag}]],
        logs: [[${logs}]],
        rank: [[${rank}]],
        SYS_MCC: [[${SYS_MCC}]],
    };

    layui.config({
        base: "/static/lay/",
        version: 202111717464
    }).extend({
        index: "lib/index",
        channel_detail: "channel/zmn.plat.channel.detail",
    }).use(['index', 'channel_detail']);

</script>
